package com.data.modules.smzh.service.impl;

import com.data.modules.smzh.entity.SmAccMonit;
import com.data.modules.smzh.mapper.SmAccMonitMapper;
import com.data.modules.smzh.mapper.SmAccMonitMapper;
import com.data.modules.smzh.service.ISmAccMonitService;
import com.data.modules.smzh.service.ISmAccMonitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 时迈人员进出监控
 * @Author: data-boot
 * @Date:   2023-01-09
 * @Version: V1.0
 */
@Service
public class SmAccMonitServiceImpl extends ServiceImpl<SmAccMonitMapper, SmAccMonit> implements ISmAccMonitService {

    @Autowired
    private SmAccMonitMapper smAccMonitMapper;
    @Override
    public List<SmAccMonit> queryLastInfo(String userName) {
        return smAccMonitMapper.searchLastInfo(userName);
    }

    @Override
    public List<Map> queryLastSosInfo(String code) {
        return smAccMonitMapper.searchLastSosInfo(code);
    }

    @Override
    public Map queryGateInfo(String userName) {

        Map map = new HashMap();
        String unitCount = smAccMonitMapper.searchUnitCount(userName);
        String gateCount = smAccMonitMapper.searchGateInfo(userName);

        map.put("unitCount",unitCount);
        map.put("gateCount",gateCount);
        map.put("total",Long.valueOf(unitCount)+Long.valueOf(gateCount));

        return map;
    }

    @Override
    public Map queryMidScreenCount(String userName) {

        Map map = new HashMap();
        String onlineCount = smAccMonitMapper.searchOnlineCount(userName);
        String total = smAccMonitMapper.searchMidScreenCount(userName);

        map.put("onlineCount",onlineCount);
        map.put("total",total);
        map.put("offline",Long.valueOf(total)-Long.valueOf(onlineCount));

        return map;
    }
}
